package csharp.cauth.properties;

import java.io.Serializable;
import java.sql.Date;

import org.bukkit.Location;
import org.bukkit.World;

import csharp.cauth.CAuth;

/**
 * @author Ярослав (CSharp) Player class for hash map saving.
 */
public class PlayerProp implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7113085279953743497L;

	/**
	 * Player ID
	 */
	private Integer id;

	/**
	 * Player login
	 */
	private String login;

	/**
	 * Player password
	 */
	private String password;

	/**
	 * Player address
	 */
	private String ip;

	/**
	 * Player last location.
	 */
	private Double x;
	private Double y;
	private Double z;
	private String world;

	/**
	 * Player registration and last login date.
	 */
	private Date registred;
	private Date lastLogin;

	/**
	 * Constructor for Player property.
	 * 
	 * @param login
	 * @param password
	 * @param ip
	 */
	public PlayerProp(String login, String password, String ip, Location lastLoc)
	{
		super();
		this.login = login;
		this.password = password;
		this.ip = ip;
		this.x = lastLoc.getX();
		this.y = lastLoc.getY();
		this.z = lastLoc.getZ();
		this.world = lastLoc.getWorld().getName();
	}

	/**
	 * Constructor for Player property.
	 * 
	 * @param id
	 * @param login
	 * @param password
	 * @param ip
	 */
	public PlayerProp(Integer id, String login, String password, String ip,
			Location lastLoc)
	{
		super();
		this.id = id;
		this.login = login;
		this.password = password;
		this.ip = ip;
		this.x = lastLoc.getX();
		this.y = lastLoc.getY();
		this.z = lastLoc.getZ();
		this.world = lastLoc.getWorld().getName();
	}

	public String getLogin()
	{
		return login;
	}

	public void setLogin(String login)
	{
		this.login = login;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}

	public String getIp()
	{
		return ip;
	}

	public void setIp(String ip)
	{
		this.ip = ip;
	}

	public Location getLastLoc()
	{
		World world2 = CAuth.instance.getServer().getWorld(world);
		Location loc = new Location(world2, x, y, z);

		return loc;
	}

	public void setLastLoc(Location lastLoc)
	{
		this.x = lastLoc.getX();
		this.y = lastLoc.getY();
		this.z = lastLoc.getZ();
		this.world = lastLoc.getWorld().getName();
	}

	public Date getRegistred()
	{
		return registred;
	}

	public void setRegistred(Date registred)
	{
		this.registred = registred;
	}

	public Date getLastLogin()
	{
		return lastLogin;
	}

	public void setLastLogin(Date lastLogin)
	{
		this.lastLogin = lastLogin;
	}

	public Integer getId()
	{
		return id;
	}

	public void setId(Integer id)
	{
		this.id = id;
	}
}
